﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;
namespace Entity
{
    public class HOCVI
    {
        private String MAHOCVI, TENHOCVI;
        float HESOHV;

        public String maHocVi
        {
            get { return MAHOCVI; }
            set { MAHOCVI = value; }
        }

        
        public String tenHocVi
        {
            get { return TENHOCVI; }
            set { TENHOCVI = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public float hesoHV
        {
            get { return HESOHV; }
            set { HESOHV = value; }
        }

        /// <summary>
        /// 
        /// </summary>

        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        public void hienthi_HocVi(DataGridView dtgHOCVI)
        {
           
                DataTable dataTable = new DataTable();
                dataTable = dataBaseAccess.getDataTable("SELECT * FROM HOCVI");
                dtgHOCVI.DataSource = dataTable;
           
        }


        public void them_HocVi(HOCVI hv)
        {
            
                String excuteString = "INSERT INTO HOCVI VALUES('" 
                                    + hv.maHocVi + "','" 
                                    + hv.tenHocVi + "'," 
                                    + hv.hesoHV + ")";
               dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void xoa_HocVi(String maHV)
        {
            String excuteString = "DELETE FROM HOCVI WHERE MAHOCVI ='" + maHV + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_HocVi(HOCVI hv)
        {
            String excuteString = "UPDATE HOCVI SET TENHOCVI =' " + hv.tenHocVi + 
                                                "', HESOHV = " + hv.hesoHV + 
                                             "WHERE MAHOCVI ='" + hv.maHocVi + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }






    }
}
